<%@page import="JavaServlet.TimeServlet.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	//打印所要输出的信息
	<%-- ${student } --%>
	<%
		Student student = (Student)request.getAttribute("student");
	%>
	<form id="ajax_form" method="post" onsubmit="return false">
		<input type="hidden" name="id" value="<%=student.getId()%>"/>
		名字：<input type="text" name="name" value="<%=student.getName()%>"/><br/>
		年龄：<input type="text" name="age" value="<%=student.getAge()%>"/><br/>
		性别：<input type="text" name="gender" value="<%=student.getGender()%>"/><br/>
			<input type="submit" value="修改" onclick="submitForm()" class="btn btn-success"/> 
	</form>
	<script src="js/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/layer/layer/layer.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/layer/layer/mylayer.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/layer/layer/util.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		function submitForm(){
			$.ajax({
				url : "${pageContext.request.contextPath}/student?method=update",
				type : "post",
				dataType : "json",
				data : $("#ajax_form").serialize(),
				success : function(jsonObj){
					console.log(jsonObj);
					if(jsonObj.code == util.SUCCESS){
						mylayer.successMsg(jsonObj.msg);
						//当你在iframe页面关闭自身时
						var index = parent.layer.getFrameIndex(window.name);
						setTimeout(function(){
							window.parent.location.reload();
						},1000);
					}else{
						mylayer.errorMsg(jsonObj.msg);
					}
				}
			});
		}
	</script>
</body>

</html>